/*
 * Project Name : NOBUNAGA
 * Created on 2007/02/02
 */
package jp.sengoku.oda {
	import mx.containers.TitleWindow;
	import mx.containers.Panel;
	import mx.controls.Button;
	import mx.events.FlexEvent;

	/**
	 * 拡張ウィンドウクラス
	 * 最大化されたり小さくなったり
	 * 
	 * @author	morimotohiroki@gmail.com
	 */
	public class MunemasaWindow extends TitleWindow {

		private var btnMini:Button;
		private var flgMini:Boolean = false;

		/**
		 * コンストラクタでござる
		 */
		public function MunemasaWindow() {
			super();
			
			addEventListener(FlexEvent.CREATION_COMPLETE, _creationCompleteHandler);	
		}
		
		private function _creationCompleteHandler(event:FlexEvent):void {
			//titleBar.addChildAt(btnMini, 0);
			
			removeEventListener(FlexEvent.CREATION_COMPLETE, _creationCompleteHandler);
		}
		
		override protected function createChildren():void {
			super.createChildren();
			
	        if (!btnMini) {
	            btnMini = new Button();
	            //btnMini.styleName = ;
	
	            //btnMini.upSkinName = "btnMiniUpSkin";
	            //btnMini.overSkinName = "btnMiniOverSkin";
	            //btnMini.downSkinName = "btnMiniDownSkin";
	            //btnMini.disabledSkinName = "btnMiniDisabledSkin";
	            btnMini.explicitWidth = btnMini.explicitHeight = 16;
	            
	            btnMini.focusEnabled = false;
	            btnMini.visible = false;
	            btnMini.enabled = enabled;
				btnMini.label = "_";
	            
	            //btnMini.addEventListener(MouseEvent.CLICK,                                          btnMini_clickHandler);
	
	            // Add the close button on top of the title/status.
	            titleBar.addChild(btnMini);
				btnMini.owner = this;
	        }
		}
		public function set showMiniButton(flg:Boolean):void {
			flgMini = flg;
			invalidateProperties();
		}
		
		public function get showMiniButton():Boolean {
			return flgMini;
		}

		override protected function commitProperties():void {
			super.commitProperties();
			
			if (btnMini) {
				btnMini.visible = flgMini;
			}
			
		}
		
	}
}